/**
 * create by young (young2f@outlook.com) on 2020/12/3
 */
'use strict';
const model = require('../base/modelBase');
const _ = require('lodash');
module.exports = app => {
    const mongoose = app.mongoose;
    const schema = mongoose.Schema;
    const connect = app.mongooseDB.get('iot');
    const json = {
        tenantCode: {type: String, required: true, desc: '租户代码'},
        tenantName: {type: String, required: true, desc: '租户名称'},
        tenantShortName: {type: String, required: true, desc: '租户简称'},
        createUser: {type: String, required: true, desc: '创建者'},
        createUsername: {type: 'string'},
        tenantAddress: {type: 'string'},
        tenantCountry: {type: 'string'},
        maxUser: {type: 'number'},
        maxRelatingTenant: {type: 'number'},
        tenantType: {type: 'string'},
        tenantCity: {type: Array},
        tenantInvalidData: {type: Date},
        tenantAdminUser: {type: 'string'},
        tenantAdminUsername: {type: 'string'},
        tenantAdminPassword: {type: 'string'},
        isChildren: {type: Boolean},
        fatherTenant: {type: 'string'},

        /**
         * 关联租户，先空着
         */
        relating: {type: 'array'},
        /**
         * 租户配置
         */
        config: {type: 'object'},


    };
    const _model = _.cloneDeep(model);
    _.assign(_model, json);
    const _schema = new schema(
        _model,
    );
    return connect.model('Tenant', _schema);
};
